<template>
  <div class="fixed-wrap">
    <div
      class="tool-fixed"
      ref="ball"
      v-element-drag="{ right: '50px', bottom: '50px' }"
    >
      <commonFun
        v-if="commonFunDialog.visible"
        :divHeight="divHeight"
        @showCommonFun="showCommonFun"
      />
      <div class="list ability" @click.stop="showCommonFun">
        <i class="el-icon-menu" style="font-size: 20px; color: #fff"></i>
        <div>常用功能</div>
      </div>

      <div
        class="list log"
        v-if="adminDetail && adminDetail.stationBind"
        @click.stop="showWorkLog"
      >
        <i class="el-icon-notebook-2" style="font-size: 20px; color: #fff"></i>
        <div>交接日志</div>
      </div>
      <div class="list" @click.stop="back" ref="list" v-if="$route.path">
        <i class="el-icon-back" style="font-size: 20px; color: #fff"></i>
        <div>返回</div>
      </div>
    </div>
  </div>
</template>
<script>
import commonFun from "./commonFun";
import { mapState } from "vuex";
export default {
  props: {},
  data() {
    return {
      ball: null,
      commonFunDialog: {
        visible: false,
      },
      divHeight: 148,
    };
  },
  computed: {
    ...mapState({
      adminDetail: (state) => state.common.adminDetail,
    }),
  },
  created() {
    document.body.addEventListener("click", () => {
      this.commonFunDialog.visible = false;
    })
  },
  methods: {
    showWorkLog() {
      this.commonFunDialog.visible = false;
      if (this.$refs.ball.dragFlag == true) {
        return;
      }
      this.$emit("HandleWorkLog");
    },

    showCommonFun() {
      if (this.$refs.ball.dragFlag == true) {
        return;
      }
      this.commonFunDialog.visible = !this.commonFunDialog.visible;
    },

    back() {
      this.commonFunDialog.visible = false;
      if (this.$refs.ball.dragFlag == true) {
        return;
      }
      this.$router.back();
    },
  },

  components: {
    commonFun,
  },
};
</script>
<style lang="scss" scoped>
.fixed-wrap {
  position: relative;
}
.tool-fixed {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  .list {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 60px;
    height: 60px;
    background: #34855b;
    border-radius: 50%;
    box-shadow: 0 2px 12px 0 rgba(52, 133, 91, 0.4);
    cursor: pointer;
    div {
      color: #fff;
      font-size: 12px;
      white-space: nowrap;
    }
  }
  .log {
    margin: 2px 0;
  }
  .ability {
    position: relative;
  }
}
</style>
